/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Eduardo
 */
@Entity
@Table(name = "Orden_Compra")
@NamedQueries({
    @NamedQuery(name = "OrdenCompra.findAll", query = "SELECT o FROM OrdenCompra o"),
    @NamedQuery(name = "OrdenCompra.findByNumeroOrdenCompra", query = "SELECT o FROM OrdenCompra o WHERE o.numeroOrdenCompra = :numeroOrdenCompra"),
    @NamedQuery(name = "OrdenCompra.findByFechaReg", query = "SELECT o FROM OrdenCompra o WHERE o.fechaReg = :fechaReg"),
    @NamedQuery(name = "OrdenCompra.findByFechaEst", query = "SELECT o FROM OrdenCompra o WHERE o.fechaEst = :fechaEst"),
    @NamedQuery(name = "OrdenCompra.findByFechaEnt", query = "SELECT o FROM OrdenCompra o WHERE o.fechaEnt = :fechaEnt"),
    @NamedQuery(name = "OrdenCompra.findByMontoTotal", query = "SELECT o FROM OrdenCompra o WHERE o.montoTotal = :montoTotal"),
    @NamedQuery(name = "OrdenCompra.findByEstado", query = "SELECT o FROM OrdenCompra o WHERE o.estado = :estado")})
public class OrdenCompra implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "NumeroOrdenCompra")
    private Integer numeroOrdenCompra;
    @Column(name = "FechaReg")
    @Temporal(TemporalType.DATE)
    private Date fechaReg;
    @Column(name = "FechaEst")
    @Temporal(TemporalType.DATE)
    private Date fechaEst;
    @Column(name = "FechaEnt")
    @Temporal(TemporalType.DATE)
    private Date fechaEnt;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "MontoTotal")
    private Double montoTotal;
    @Column(name = "Estado")
    private Integer estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "numOrdCompra", fetch = FetchType.LAZY)
    private List<DetalleOrden> detalleOrdenList;
    @JoinColumn(name = "IdProveedor", referencedColumnName = "IdProveedor")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Proveedor idProveedor;
    @JoinColumn(name = "IdPersonal", referencedColumnName = "IdPersonal")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Personal idPersonal;

    public OrdenCompra() {
    }

    public OrdenCompra(Integer numeroOrdenCompra) {
        this.numeroOrdenCompra = numeroOrdenCompra;
    }

    public Integer getNumeroOrdenCompra() {
        return numeroOrdenCompra;
    }

    public void setNumeroOrdenCompra(Integer numeroOrdenCompra) {
        this.numeroOrdenCompra = numeroOrdenCompra;
    }

    public Date getFechaReg() {
        return fechaReg;
    }

    public void setFechaReg(Date fechaReg) {
        this.fechaReg = fechaReg;
    }

    public Date getFechaEst() {
        return fechaEst;
    }

    public void setFechaEst(Date fechaEst) {
        this.fechaEst = fechaEst;
    }

    public Date getFechaEnt() {
        return fechaEnt;
    }

    public void setFechaEnt(Date fechaEnt) {
        this.fechaEnt = fechaEnt;
    }

    public Double getMontoTotal() {
        return montoTotal;
    }

    public void setMontoTotal(Double montoTotal) {
        this.montoTotal = montoTotal;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    public List<DetalleOrden> getDetalleOrdenList() {
        return detalleOrdenList;
    }

    public void setDetalleOrdenList(List<DetalleOrden> detalleOrdenList) {
        this.detalleOrdenList = detalleOrdenList;
    }

    public Proveedor getIdProveedor() {
        return idProveedor;
    }

    public void setIdProveedor(Proveedor idProveedor) {
        this.idProveedor = idProveedor;
    }

    public Personal getIdPersonal() {
        return idPersonal;
    }

    public void setIdPersonal(Personal idPersonal) {
        this.idPersonal = idPersonal;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (numeroOrdenCompra != null ? numeroOrdenCompra.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdenCompra)) {
            return false;
        }
        OrdenCompra other = (OrdenCompra) object;
        if ((this.numeroOrdenCompra == null && other.numeroOrdenCompra != null) || (this.numeroOrdenCompra != null && !this.numeroOrdenCompra.equals(other.numeroOrdenCompra))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "models.OrdenCompra[ numeroOrdenCompra=" + numeroOrdenCompra + " ]";
    }
    
}
